package com.future.templateMethod;

/**
 * Description:
 *
 * @author weiruibai.vendor
 * Date: 2021/9/9 10:54
 */
public class Main_TemplateMethod {

    public static void main(String[] args) {
        Template template = new TemplateCustom();

        template.doPost();
        System.out.println("=====");


        Template2 t = new MyTemplate();
        Object o = t.doPost();
        System.out.println(o);
    }

}

class TemplateCustom extends Template {


    @Override
    void method1() {
        System.out.println("custom metho1");
    }

    @Override
    void method2() {
        System.out.println("custom metho2");
    }
}

abstract class Template {

    public void doPost() {
        method1();
        method2();
    }

    abstract void method1();

    abstract void method2();
}

class MyTemplate implements Template2{

    @Override
    public void method1() {
        System.out.println("Mytemplate method1");
    }

    @Override
    public void method2() {
        System.out.println("Mytemplate method1");
    }
}


interface Template2{

    default Object doPost(){
        method1();
        method2();
        return "Good";
    }

    void method1();
    void method2();
}